package com.mo.modular.auth.util;

import java.util.regex.Pattern;

public class MacUtil {

	private static final String patternMac="^([A-Fa-f0-9]{2}[-,:]){5}[A-Fa-f0-9]{2}$";
	
	/**
	 * 验证mac合法性
	 *
	 */
    public static boolean isMac(String mac){
    	mac = mac.substring(0,17);
    	if(Pattern.compile(patternMac).matcher(mac).find()){  
    		 return true;
    	 }else{
    		 return false;
    	 }
    }
	/*public static boolean isMac(String mac){
    	if(mac.length()==12){  
    		 return true;
    	 }else{
    		 return false;
    	 }
    }*/
    
    /**
	 * 大写去除:分隔符
	 *
	 */
    public static String format(String mac){
    	String replace = mac.replace(":", "");
    	return replace.toUpperCase();
    }
    
}
